package net.wanho.employ.service.impl;

import net.wanho.employ.dto.LoginDTO;
import net.wanho.employ.entity.Admin;
import net.wanho.employ.exception.LoginErrorException;
import net.wanho.employ.mapper.AdminMapper;
import net.wanho.employ.service.LoginService;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;

/**
 * Author：汤小洋
 * Date：2024-03-22 15:41
 * Description：<描述>
 */
@Service
public class LoginServiceImpl implements LoginService {

    @Resource
    private AdminMapper adminMapper;

    @Override
    public Admin login(LoginDTO loginDTO) {
        Admin admin = adminMapper.selectOne(loginDTO);
        if (ObjectUtils.isEmpty(admin)){
            throw new LoginErrorException("用户名或密码错误");
        }
        return admin;
    }

}
